package cn.whb.hrm.feign;

import cn.whb.hrm.doc.CourseDoc;
import cn.whb.hrm.query.CourseDocQuery;
import cn.whb.hrm.util.AjaxResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class CourseDocFallbackFactory implements FallbackFactory<CourseDocFeignClient>{
    @Override
    public CourseDocFeignClient create(Throwable throwable) {
        return new CourseDocFeignClient() {
            @Override
            public AjaxResult courseOnline(CourseDoc doc) {
                return AjaxResult.me().setSuccess(false).setResultObj("课程上线失败，请稍后重试");
            }

            @Override
            public AjaxResult courseOffLine(Long id) {
                return AjaxResult.me().setSuccess(false).setResultObj("课程下线失败，请稍后重试");
            }

            @Override
            public AjaxResult queryCourses(CourseDocQuery docQuery) {
                return AjaxResult.me().setSuccess(false).setResultObj("课程查询失败，请稍后重试");
            }
        };
    }
}
